let kidsWithCandies = function(candies, extraCandies) {
    let maxCandies = Math.max(...candies);
    console.log(maxCandies);
    let result = [];
    for (let i = 0; i < candies.length; i++) {
        result[i] = candies[i] + extraCandies >= maxCandies;
    }
    return result;
};

console.log(kidsWithCandies([4, 2, 1, 1, 2], 1));